﻿<form action="{:U('Index/updataTag')}" method="post" id="myform">
<div class="modal-body row" id="myModal">
<foreach name="tag" item="tagTitle">
    <div class="col-xs-3">
        <select multiple="multiple" title="{$tagTitle['tag_content']}" class="select" name="tag[]">
        <foreach name="tagTitle['cate']" item="tagCont">
          <if condition="$tagCont['pass'] eq 1">
            <option value="{$tagCont['tag_id']}" selected="selected">{$tagCont['tag_content']}</option>
            <else/>
            <option value="{$tagCont['tag_id']}" >{$tagCont['tag_content']}</option>
            </if>
         </foreach>
        </select>
    </div>
    </foreach>
</div>
<div class="modal-footer">
    <input type="hidden" value="{$type}" name="type" id="hid" />
    <button type="submit" class="btn btn-success queren" id="invite-sub" data-dismiss="modal">确认</button>
</div>
</form>
<script src="__PUBLIC__/js/bootstrap-select.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("select").selectpicker({ style: 'btn-block btn-primary', menuStyle: 'dropdown-inverse' });
		
	$('.queren').click(function(){
	var url="{:U('Index/updataTag')}";
    var senData=$('#myform').serialize();
	var type=$('#hid').val();
	$.ajax({
		url:url,
		type:'POST',
		dataType:"JSON",
		data:senData,
		success:function(data){
			if(type==1){
				$('#fav').html('');
				for( var tag in data)
				{
					var color=Math.round(Math.random()*10)%6;
					if(color==0){color=color+1;}
					$('#fav').append('<span><span class="btn tag tag-'+color+'">'+data[tag]['tag_content']+'</span></span>');
					}
				}
			else if(type==2){
		      $('#sav').html('');
				for( var tag in data)
				{
					$('#sav').append('<span><span class="btn tag tag-'+color+'">'+data[tag]['tag_content']+'</span></span>');
					}			
				}
			}
		});

		});
    });
</script>
